package com.ivanceras.shared.db;

import com.ivanceras.shared.exception.DatabaseException;



public interface IDatabase{
	
	public void beginTransaction() throws DatabaseException;
	public void commitTransaction() throws DatabaseException;
	public void rollbackTransaction() throws DatabaseException;
	public boolean isTransacted() throws DatabaseException;
	
	DAO[] select(IModelDef model, Join join, Filter[] filters, Integer offset, Integer limit, Boolean doCount, Order[] orders) throws DatabaseException;

	boolean createModel(IModelDef model) throws DatabaseException;
	
	DAO insert(DAO dao, IModelDef model) throws DatabaseException;
	
	DAO update(DAO dao, IModelDef model, Filter[] filters) throws DatabaseException;
	
	int delete(IModelDef model, Filter[] filters) throws DatabaseException;
	
	int empty(IModelDef model) throws DatabaseException;
	
	boolean drop(IModelDef model) throws DatabaseException;

	boolean isClosed(); 

	
	/**
	 * This method is called when a connection is to be reused - it should ensure that there are no transactions pending 
	 * (it should rollback if there is), and do any other required housecleaning if needed, so the connection can be re-used.
	 * @return
	 */
	boolean reset();
	Integer getTotalRecords(String schema, String modelName)
			throws DatabaseException;
	IModelDef getModelMetaData(String tableName) throws DatabaseException;
//	ResultSet executeSelectSQL(String sql, Object[] parameters)
//			throws DatabaseException;
	String[] getTableNames(String schema, String tablePattern)
			throws DatabaseException;


}
